clear all
set memo 100m
capture log close

local filename selection

log using selection, replace text

local output_dir draft
local output_tex1 `filename'.tex

cd "C:\Users\rujia\Dropbox\Replication\treatyports"

/* notes on data
data\nonSubgroup.dta: not the 57 coastal/yangtze group
data\subgroup.dta: the 57 coastal/yangtze group



***/

use "data\subgroup.dta", clear


append using "data\nonSubgroup.dta"

replace treatyports=1 if cmcyear<.
replace treatyports=0 if cmcyear==.



label var coastal2  "Coastal"
label var yangtze "Yangtze"
label var hpopu1776 "Popu in 1776"
label var hpopu1820 "Popu in 1820"
label var silk "Silk"
label var tea "Tea"
label var landtax "Land tax in 1820"
label var dis_yunhe1 "Distance to Grand Canal"
label var longitude "Longitude"
label var latitude "Latitude"
label var taipingrrebellion  "Affected by Taiping Rebellion"

#delimit ;
eststo clear;


eststo: reg treatyports coastal2 yangtze;
estadd scalar nobs=e(N);
estadd scalar rsquare=e(r2);


eststo: reg treatyports coastal2 yangtze hpopu1776 hpopu1820 silk tea landtax  dis_yunhe1 longitude latitude taipingrrebellion ; 
estadd scalar nobs=e(N);
estadd scalar rsquare=e(r2);


eststo: reg treatyports hpopu1776 hpopu1820 if subgroup==.;
estadd scalar nobs=e(N);
estadd scalar rsquare=e(r2);

eststo: reg treatyport hpopu1776 hpopu1820 silk tea landtax  dis_yunhe1 longitude latitude taipingrrebellion if subgroup==.;
estadd scalar nobs=e(N);
estadd scalar rsquare=e(r2);

esttab using draft/`output_tex1', replace
	width(\hsize) 
	mlabel (, depvar)
	b(3)
	se(3)
	noconstant
	star(* 0.10 ** 0.05 *** 0.01)
	keep(
coastal2 
yangtze 
hpopu1776
hpopu1820 
silk tea 
landtax 

dis_yunhe1
 longitude 
 latitude 
taipingrrebellion	
 )
 order (
coastal2 
yangtze 
hpopu1776
hpopu1820 
silk tea 
landtax 

dis_yunhe1
 longitude 
 latitude 
taipingrrebellion	
 )
		

		
	label
	stats(
	
		nobs
		rsquare
		, 
		labels(
		
			"\# observations"
			"R-squared"
			) 
		fmt(0)
		layout(@)
		)
	nonotes
	;
